/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2014_08_20			*/
/*	File:		GtDrSend.cpp			*/
/********************************************************/

#include "GtUdp.h"

int main(int argc, char* argv[])
{
	int iLength = 0;
	GtNet::CGtUdp CUdp;
	UCHAR* puszPacket = NULL;
	char szUrl[GT_URL] = "127.0.0.1:31813";
	UCHAR uszStop[] = {
		0x93, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x45, 0x00, 0x01, 0x02,
		0x00, 0x00, 0x40, 0x00, 0x40, 0x11, 0xf8, 0x48, 0x0a, 0x79, 0x15, 0xdd, 0x0a, 0x6f, 0x16, 0xde,
		0xdf, 0xb3, 0x07, 0x15, 0x00, 0xee, 0x1d, 0x83, 0x04, 0xf6, 0x00, 0xe6, 0xf3, 0x66, 0xa7, 0xb6,
		0x09, 0xfe, 0x7d, 0x5f, 0x9b, 0xff, 0xbc, 0x8c, 0xc9, 0x8f, 0x6a, 0x76, 0x2c, 0x1d, 0x37, 0x30,
		0x30, 0x33, 0x33, 0x31, 0x30, 0x31, 0x35, 0x37, 0x35, 0x32, 0x70, 0x70, 0x70, 0x31, 0x30, 0x30,
		0x38, 0x36, 0x35, 0x39, 0x36, 0x65, 0x35, 0x34, 0x63, 0x04, 0x06, 0x3c, 0x1e, 0xe0, 0x0e, 0x29,
		0x06, 0x00, 0x00, 0x00, 0x00, 0x28, 0x06, 0x00, 0x00, 0x00, 0x02, 0x20, 0x07, 0x5a, 0x58, 0x55,
		0x41, 0x53, 0x01, 0x0e, 0x78, 0x70, 0x61, 0x6e, 0x67, 0x78, 0x64, 0x40, 0x61, 0x64, 0x73, 0x6c,
		0x1f, 0x1c, 0x30, 0x35, 0x30, 0x36, 0x31, 0x30, 0x30, 0x31, 0x63, 0x38, 0x30, 0x30, 0x30, 0x30,
		0x30, 0x30, 0x31, 0x34, 0x62, 0x66, 0x36, 0x62, 0x38, 0x32, 0x36, 0x33, 0x08, 0x06, 0x3c, 0x1e,
		0xec, 0xd0, 0x2d, 0x06, 0x00, 0x00, 0x00, 0x01, 0x2e, 0x06, 0x00, 0x00, 0x01, 0x3d, 0x2a, 0x06,
		0x00, 0x00, 0x03, 0xe1, 0x2b, 0x06, 0x00, 0x00, 0x01, 0x90, 0x30, 0x06, 0x00, 0x00, 0x00, 0x04,
		0x2f, 0x06, 0x00, 0x00, 0x00, 0x05, 0x34, 0x06, 0x00, 0x00, 0x00, 0x00, 0x35, 0x06, 0x00, 0x00,
		0x00, 0x00, 0x31, 0x06, 0x00, 0x00, 0x00, 0x01, 0x05, 0x06, 0x56, 0x10, 0x01, 0xc8, 0x3d, 0x06,
		0x00, 0x00, 0x00, 0x0d, 0x57, 0x1e, 0x61, 0x74, 0x6d, 0x20, 0x35, 0x2f, 0x30, 0x2f, 0x36, 0x3a,
		0x31, 0x36, 0x2e, 0x34, 0x35, 0x36, 0x20, 0x30, 0x2f, 0x30, 0x2f, 0x30, 0x2f, 0x30, 0x2f, 0x30,
		0x2f, 0x30, 0x06, 0x06, 0x00, 0x00, 0x00, 0x02, 0x07, 0x06, 0x00, 0x00, 0x00, 0x01,
	};
	UCHAR uszStart[] = {
		0x93, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd2, 0x45, 0x00, 0x00, 0xd2,
		0x00, 0x00, 0x40, 0x00, 0x40, 0x11, 0xf8, 0x78, 0x0a, 0x79, 0x15, 0xdd, 0x0a, 0x6f, 0x16, 0xde,
		0x9e, 0xf9, 0x07, 0x15, 0x00, 0xbe, 0xff, 0x82, 0x04, 0x5c, 0x00, 0xb6, 0x7e, 0xfd, 0xa6, 0x54,
		0x7e, 0x30, 0x22, 0x1c, 0x95, 0xa9, 0xea, 0xab, 0xf1, 0xd4, 0x5b, 0x12, 0x2c, 0x1d, 0x37, 0x30,
		0x30, 0x33, 0x33, 0x31, 0x30, 0x31, 0x35, 0x37, 0x35, 0x32, 0x70, 0x70, 0x70, 0x31, 0x30, 0x30,
		0x38, 0x36, 0x35, 0x39, 0x36, 0x65, 0x35, 0x34, 0x63, 0x04, 0x06, 0x3c, 0x1e, 0xe0, 0x0e, 0x29,
		0x06, 0x00, 0x00, 0x00, 0x00, 0x28, 0x06, 0x00, 0x00, 0x00, 0x01, 0x20, 0x07, 0x5a, 0x58, 0x55,
		0x41, 0x53, 0x01, 0x0e, 0x78, 0x70, 0x61, 0x6e, 0x67, 0x78, 0x64, 0x40, 0x61, 0x64, 0x73, 0x6c,
		0x1f, 0x1c, 0x30, 0x35, 0x30, 0x36, 0x31, 0x30, 0x30, 0x31, 0x63, 0x38, 0x30, 0x30, 0x30, 0x30,
		0x30, 0x30, 0x31, 0x34, 0x62, 0x66, 0x36, 0x62, 0x38, 0x32, 0x36, 0x33, 0x08, 0x06, 0x3c, 0x1e,
		0xec, 0xd0, 0x2d, 0x06, 0x00, 0x00, 0x00, 0x01, 0x05, 0x06, 0x56, 0x10, 0x01, 0xc8, 0x3d, 0x06,
		0x00, 0x00, 0x00, 0x0d, 0x57, 0x1e, 0x61, 0x74, 0x6d, 0x20, 0x35, 0x2f, 0x30, 0x2f, 0x36, 0x3a,
		0x31, 0x36, 0x2e, 0x34, 0x35, 0x36, 0x20, 0x30, 0x2f, 0x30, 0x2f, 0x30, 0x2f, 0x30, 0x2f, 0x30,
		0x2f, 0x30, 0x06, 0x06, 0x00, 0x00, 0x00, 0x02, 0x07, 0x06, 0x00, 0x00, 0x00, 0x01,
	};

	if (GT_SUCCESS == strcmp("start", argv[1])) {
		iLength = sizeof(uszStart);
		puszPacket = uszStart;
	}
	else {
		iLength = sizeof(uszStop);
		puszPacket = uszStop;
	}

	if (GT_SUCCESS == CUdp.GtNetInitSend(szUrl)) {
		CUdp.GtNetSetTimeOut(1, 0);
		if (CUdp.GtNetSend(puszPacket, iLength) > 0) {
			GT_PRINT("Success to GtNetSend\n");
		}
		else {
			GT_ERROR("Failed to GtNetSend\n");
		}
		CUdp.GtNetClose();
	}
	else {
		GT_ERROR("Failed to GtNetInitSend\n");
	}

	return GT_SUCCESS;
}
